package com.job.homework;

/**
 * @author asus
 * @version 1.0
 * @since 2022-07-01 17:32:46
 */
public class Homework0701 {
    public static void main(String[] args) {
        int[] array1 = new int[3];
        //静态初始化，指定数据
        String[] array2 = {"one","two","three","four"};
//        length 属性 获取数据个数，也叫数组的长度
        System.out.println(array2.length);

//        数组通过下标 来 获取 某个数据 下标index从0 开始
        System.out.println(array2[1]);
        System.out.println(array2[array2.length-1]);
//        下标不能越界 0~长度-1
        System.out.println(array2[2]);
        System.out.println("发红包");
        array2[2] = "二货";
        System.out.println(array2[2]);
//        遍历 是最基本的操作，按照某种顺序 逐个访问数据
        for (int i = 0; i < array2.length; i++) {
            System.out.println(i+"\t"+array2[i]);

        }

        for (int i = array2.length-1; i >=0; i--) {
            System.out.println (i+"~~~~~~~"+array2[i]);

        }
    }
}

